## Read in the data
### Oil spills by county
ca_oil_spills <- read_sf(here("data", "oil_spills", "Oil_Spill_Incident_Tracking_%5Bds394%5D.shp")) %>%
clean_names() %>%
rename(object_id = objectid,
dfg_control = dfgcontrol,
oes_number = oesnumber,
date = dateofinci,
inland_marine = inlandmari,
time = timeofinci,
location = specificlo,
city = localecity,
county_name = localecoun)
### California counties shape file
ca_counties <- read_sf(here("data", "ca_counties", "CA_Counties_TIGER2016.shp")) %>%
clean_names() %>%
dplyr::select(name) %>%
rename(county_name = name)
## Oil spill data wrangling
ca_oil_spills_tidy <- ca_oil_spills %>%
mutate(date = as.Date(date)) %>%
mutate(date = ymd(date)) %>%
mutate(year = year(date)) %>%
dplyr::select(date, year, longitude, latitude, city, county_name, inland_marine)
Interactive map of California oil spills in 2008
tmap_mode("view")
tm_shape(ca_counties) +
tm_fill("county_name") +
tm_shape(ca_oil_spills_tidy) +
tm_dots()